#ifndef _DV_OSD_H_
#define _DV_OSD_H_

extern XDATA BYTE UnicodeIndexBuffer[8];

#define PAGE			0xff
#define ChangePage(p)		WriteTW88(PAGE,p)

#define WIN_START		0L
#define WIN_BUFX		2048//1024//2048
#define WIN_BUFY		2048//1024//2048
#define WIN_W			480
#define WIN_H			272

#define RGB565	0x02

//	OSD Registers
#define OSD_PAGER							(0x700)

#define OSD_MODE						(OSD_PAGER+0x00)
#define OSD_STATUS						(OSD_PAGER+0x01)
#define OSD_WDATAPORT					(OSD_PAGER+0x02)
#define OSD_CONTROL1					(OSD_PAGER+0x03)
#define OSD_RLCCTRL						(OSD_PAGER+0x04)
#define OSD_RLCDATACNT					(OSD_PAGER+0x05)

#define OSD_FILLCOLOR_H				(OSD_PAGER+0x0e)
#define OSD_FILLCOLOR_L					(OSD_PAGER+0x0f)

#define OSD_8BITEXPANSIONTABLE0		(OSD_PAGER+0x10)
#define OSD_8BITEXPANSIONTABLE1		(OSD_PAGER+0x11)
#define OSD_8BITEXPANSIONTABLE2		(OSD_PAGER+0x12)
#define OSD_8BITEXPANSIONTABLE3		(OSD_PAGER+0x13)
#define OSD_8BITEXPANSIONTABLE4		(OSD_PAGER+0x14)
#define OSD_8BITEXPANSIONTABLE5		(OSD_PAGER+0x15)
#define OSD_8BITEXPANSIONTABLE6		(OSD_PAGER+0x16)
#define OSD_8BITEXPANSIONTABLE7		(OSD_PAGER+0x17)
#define OSD_8BITEXPANSIONTABLE8		(OSD_PAGER+0x18)
#define OSD_8BITEXPANSIONTABLE9		(OSD_PAGER+0x19)
#define OSD_8BITEXPANSIONTABLE10		(OSD_PAGER+0x1a)
#define OSD_8BITEXPANSIONTABLE11		(OSD_PAGER+0x1b)
#define OSD_8BITEXPANSIONTABLE12		(OSD_PAGER+0x1c)
#define OSD_8BITEXPANSIONTABLE13		(OSD_PAGER+0x1d)
#define OSD_8BITEXPANSIONTABLE14		(OSD_PAGER+0x1e)
#define OSD_8BITEXPANSIONTABLE15		(OSD_PAGER+0x1f)

#define OSD_16BITEXPANSIONTABLE0_H	(OSD_PAGER+0x20)
#define OSD_16BITEXPANSIONTABLE0_L	(OSD_PAGER+0x21)
#define OSD_16BITEXPANSIONTABLE1_H	(OSD_PAGER+0x22)
#define OSD_16BITEXPANSIONTABLE1_L	(OSD_PAGER+0x23)
#define OSD_16BITEXPANSIONTABLE2_H	(OSD_PAGER+0x24)
#define OSD_16BITEXPANSIONTABLE2_L	(OSD_PAGER+0x25)
#define OSD_16BITEXPANSIONTABLE3_H	(OSD_PAGER+0x26)
#define OSD_16BITEXPANSIONTABLE3_L	(OSD_PAGER+0x27)
#define OSD_16BITEXPANSIONTABLE4_H	(OSD_PAGER+0x28)
#define OSD_16BITEXPANSIONTABLE4_L	(OSD_PAGER+0x29)
#define OSD_16BITEXPANSIONTABLE5_H	(OSD_PAGER+0x2a)
#define OSD_16BITEXPANSIONTABLE5_L	(OSD_PAGER+0x2b)
#define OSD_16BITEXPANSIONTABLE6_H	(OSD_PAGER+0x2c)
#define OSD_16BITEXPANSIONTABLE6_L	(OSD_PAGER+0x2d)
#define OSD_16BITEXPANSIONTABLE7_H	(OSD_PAGER+0x2e)
#define OSD_16BITEXPANSIONTABLE7_L	(OSD_PAGER+0x2f)
#define OSD_16BITEXPANSIONTABLE8_H	(OSD_PAGER+0x30)
#define OSD_16BITEXPANSIONTABLE8_L	(OSD_PAGER+0x31)
#define OSD_16BITEXPANSIONTABLE9_H	(OSD_PAGER+0x32)
#define OSD_16BITEXPANSIONTABLE9_L	(OSD_PAGER+0x33)
#define OSD_16BITEXPANSIONTABLE10_H	(OSD_PAGER+0x34)
#define OSD_16BITEXPANSIONTABLE10_L	(OSD_PAGER+0x35)
#define OSD_16BITEXPANSIONTABLE11_H	(OSD_PAGER+0x36)
#define OSD_16BITEXPANSIONTABLE11_L	(OSD_PAGER+0x37)
#define OSD_16BITEXPANSIONTABLE12_H	(OSD_PAGER+0x38)
#define OSD_16BITEXPANSIONTABLE12_L	(OSD_PAGER+0x39)
#define OSD_16BITEXPANSIONTABLE13_H	(OSD_PAGER+0x3a)
#define OSD_16BITEXPANSIONTABLE13_L	(OSD_PAGER+0x3b)
#define OSD_16BITEXPANSIONTABLE14_H	(OSD_PAGER+0x3c)
#define OSD_16BITEXPANSIONTABLE14_L	(OSD_PAGER+0x3d)
#define OSD_16BITEXPANSIONTABLE15_H	(OSD_PAGER+0x3e)
#define OSD_16BITEXPANSIONTABLE15_L	(OSD_PAGER+0x3f)

#define CONVERSION_SOURCECOLOR1_H	(OSD_PAGER+0x40)
#define CONVERSION_SOURCECOLOR1_L	(OSD_PAGER+0x41)
#define CONVERSION_SOURCECOLOR2_H	(OSD_PAGER+0x42)
#define CONVERSION_SOURCECOLOR2_L	(OSD_PAGER+0x43)
#define CONVERSION_SOURCECOLOR3_H	(OSD_PAGER+0x44)
#define CONVERSION_SOURCECOLOR3_L	(OSD_PAGER+0x45)
#define CONVERSION_SOURCECOLOR4_H	(OSD_PAGER+0x46)
#define CONVERSION_SOURCECOLOR4_L	(OSD_PAGER+0x47)

#define CONVERSION_TARGETCOLOR1_H	(OSD_PAGER+0x48)
#define CONVERSION_TARGETCOLOR1_L	(OSD_PAGER+0x49)
#define CONVERSION_TARGETCOLOR2_H	(OSD_PAGER+0x4a)
#define CONVERSION_TARGETCOLOR2_L	(OSD_PAGER+0x4b)
#define CONVERSION_TARGETCOLOR3_H	(OSD_PAGER+0x4c)
#define CONVERSION_TARGETCOLOR3_L	(OSD_PAGER+0x4d)
#define CONVERSION_TARGETCOLOR4_H	(OSD_PAGER+0x4e)
#define CONVERSION_TARGETCOLOR4_L	(OSD_PAGER+0x4f)

#define SELECTIVE_OVERWRITECOLOR1_H	(OSD_PAGER+0x50)
#define SELECTIVE_OVERWRITECOLOR1_L	(OSD_PAGER+0x51)
#define SELECTIVE_OVERWRITECOLOR2_H	(OSD_PAGER+0x52)
#define SELECTIVE_OVERWRITECOLOR2_L	(OSD_PAGER+0x53)
#define SELECTIVE_OVERWRITECOLOR3_H	(OSD_PAGER+0x54)
#define SELECTIVE_OVERWRITECOLOR3_L	(OSD_PAGER+0x55)
#define SELECTIVE_OVERWRITECOLOR4_H	(OSD_PAGER+0x56)
#define SELECTIVE_OVERWRITECOLOR4_L	(OSD_PAGER+0x57)

#define SOURCE_MEMORYBASE_H			(OSD_PAGER+0x60)
#define SOURCE_MEMORYBASE_M			(OSD_PAGER+0x61)
#define SOURCE_MEMORYBASE_L			(OSD_PAGER+0x62)
#define SOURCE_MEMORY_HLENGTH		(OSD_PAGER+0x63)
#define SOURCE_HSTART_H				(OSD_PAGER+0x64)
#define SOURCE_HSTART_L				(OSD_PAGER+0x65)
#define SOURCE_VSTART_H				(OSD_PAGER+0x66)
#define SOURCE_VSTART_L				(OSD_PAGER+0x67)

#define TRANSFER_HLENGTH_H			(OSD_PAGER+0x68)
#define TRANSFER_HLENGTH_L			(OSD_PAGER+0x69)
#define TRANSFER_VLENGTH_H			(OSD_PAGER+0x6a)
#define TRANSFER_VLENGTH_L				(OSD_PAGER+0x6b)

#define TARGET_MEMORYBASE_H			(OSD_PAGER+0x70)
#define TARGET_MEMORYBASE_M			(OSD_PAGER+0x71)
#define TARGET_MEMORYBASE_L			(OSD_PAGER+0x72)
#define TARGET_MEMORY_HLENGTH		(OSD_PAGER+0x73)
#define TARGET_HSTART_H				(OSD_PAGER+0x74)
#define TARGET_HSTART_L				(OSD_PAGER+0x75)
#define TARGET_VSTART_H				(OSD_PAGER+0x76)
#define TARGET_VSTART_L				(OSD_PAGER+0x77)

#define OSD_CONTROL2					(OSD_PAGER+0x78)

#define OSD_LUT_CONTROL				(OSD_PAGER+0x7a)
#define OSD_LUT_ADDRINDEX				(OSD_PAGER+0x7b)
#define OSD_LUT_DATAATTR				(OSD_PAGER+0x7c)		
#define OSD_LUT_DATAR					(OSD_PAGER+0x7d)
#define OSD_LUT_DATAG					(OSD_PAGER+0x7e)
#define OSD_LUT_DATAB					(OSD_PAGER+0x7f)

#define WIN0_CONTROL					(OSD_PAGER+0x80)
#define WIN0_SCREENHSTART_H			(OSD_PAGER+0x81)
#define WIN0_SCREENHSTART_L			(OSD_PAGER+0x82)
#define WIN0_SCREENVSTART_H			(OSD_PAGER+0x83)
#define WIN0_SCREENVSTART_L			(OSD_PAGER+0x84)
#define WIN0_HLENGTH_H					(OSD_PAGER+0x85)
#define WIN0_HLENGTH_L					(OSD_PAGER+0x86)
#define WIN0_VLENGTH_H					(OSD_PAGER+0x87)
#define WIN0_VLENGTH_L					(OSD_PAGER+0x88)
#define WIN0_MEMORYBASE_H				(OSD_PAGER+0x89)
#define WIN0_MEMORYBASE_M				(OSD_PAGER+0x8a)
#define WIN0_MEMORYBASE_L				(OSD_PAGER+0x8b)
#define WIN0_MEMORY_HLENGTH			(OSD_PAGER+0x8c)
#define WIN0_MEMORY_VLENGTH			(OSD_PAGER+0x8d)
#define WIN0_MEMORYHSTART_H			(OSD_PAGER+0x8e)
#define WIN0_MEMORYHSTART_L			(OSD_PAGER+0x8f)
#define WIN0_MEMORYVSTART_H			(OSD_PAGER+0x90)
#define WIN0_MEMORYVSTART_L			(OSD_PAGER+0x91)
#define WIN0_GLOBALALPHA_VALUE		(OSD_PAGER+0x92)

#define WIN1_CONTROL					(OSD_PAGER+0xa0)
#define WIN1_SCREENHSTART_H			(OSD_PAGER+0xa1)
#define WIN1_SCREENHSTART_L			(OSD_PAGER+0xa2)
#define WIN1_SCREENVSTART_H			(OSD_PAGER+0xa3)
#define WIN1_SCREENVSTART_L			(OSD_PAGER+0xa4)
#define WIN1_HLENGTH_H					(OSD_PAGER+0xa5)
#define WIN1_HLENGTH_L					(OSD_PAGER+0xa6)
#define WIN1_VLENGTH_H					(OSD_PAGER+0xa7)
#define WIN1_VLENGTH_L					(OSD_PAGER+0xa8)
#define WIN1_MEMORYBASE_H				(OSD_PAGER+0xa9)
#define WIN1_MEMORYBASE_M				(OSD_PAGER+0xaa)
#define WIN1_MEMORYBASE_L				(OSD_PAGER+0xab)
#define WIN1_MEMORY_HLENGTH			(OSD_PAGER+0xac)
#define WIN1_MEMORY_VLENGTH			(OSD_PAGER+0xad)
#define WIN1_MEMORYHSTART_H			(OSD_PAGER+0xae)
#define WIN1_MEMORYHSTART_L			(OSD_PAGER+0xaf)
#define WIN1_MEMORYVSTART_H			(OSD_PAGER+0xb0)
#define WIN1_MEMORYVSTART_L			(OSD_PAGER+0xb1)
#define WIN1_GLOBALALPHA_VALUE		(OSD_PAGER+0xb2)

#define WIN4_CONTROL					(OSD_PAGER+0xc0)
#define WIN4_SCREENHSTART_H			(OSD_PAGER+0xc1)
#define WIN4_SCREENHSTART_L			(OSD_PAGER+0xc2)
#define WIN4_SCREENVSTART_H			(OSD_PAGER+0xc3)
#define WIN4_SCREENVSTART_L			(OSD_PAGER+0xc4)
#define WIN4_HLENGTH_H					(OSD_PAGER+0xc5)
#define WIN4_HLENGTH_L					(OSD_PAGER+0xc6)
#define WIN4_VLENGTH_H					(OSD_PAGER+0xc7)
#define WIN4_VLENGTH_L					(OSD_PAGER+0xc8)
#define WIN4_MEMORYBASE_H				(OSD_PAGER+0xc9)
#define WIN4_MEMORYBASE_M				(OSD_PAGER+0xca)
#define WIN4_MEMORYBASE_L				(OSD_PAGER+0xcb)
#define WIN4_MEMORY_HLENGTH			(OSD_PAGER+0xcc)
#define WIN4_MEMORY_VLENGTH			(OSD_PAGER+0xcd)
#define WIN4_MEMORYHSTART_H			(OSD_PAGER+0xce)
#define WIN4_MEMORYHSTART_L			(OSD_PAGER+0xcf)
#define WIN4_MEMORYVSTART_H			(OSD_PAGER+0xd0)
#define WIN4_MEMORYVSTART_L			(OSD_PAGER+0xd1)
#define WIN4_GLOBALALPHA_VALUE		(OSD_PAGER+0xd2)

#define WIN4_COLORKEY0_H				(OSD_PAGER+0xd4)
#define WIN4_COLORKEY0_L				(OSD_PAGER+0xd5)
#define WIN4_COLORKEY1_H				(OSD_PAGER+0xd6)
#define WIN4_COLORKEY1_L				(OSD_PAGER+0xd7)
#define WIN4_COLORKEY2_H				(OSD_PAGER+0xd8)
#define WIN4_COLORKEY2_L				(OSD_PAGER+0xd9)
#define WIN4_COLORKEY3_H				(OSD_PAGER+0xda)
#define WIN4_COLORKEY3_L				(OSD_PAGER+0xdb)
#define WIN4_COLORKER0ALPHA_VALUE	(OSD_PAGER+0xdc)
#define WIN4_COLORKER1ALPHA_VALUE	(OSD_PAGER+0xdd)
#define WIN4_COLORKER2ALPHA_VALUE	(OSD_PAGER+0xde)
#define WIN4_COLORKER3ALPHA_VALUE	(OSD_PAGER+0xdf)

#define OSD_VERTICALACTIVE_STATUS		(OSD_PAGER+0xf0)
#define OSD_SELECT_FORPATH			(OSD_PAGER+0xf8)


typedef struct ST_LUT
{
	BYTE R;
	BYTE G;
	BYTE B;
	BYTE dummy;
}ST_LUT_t;

typedef struct tagPOINT
{
    LONG  x;
    LONG  y;
} Point,*PPOINT;

//	OSD Function
void OSD_SetSourceMemoryPositionBase(U32 addr);
U32 OSD_GetSourceMemoryPositionBase(void);
void OSD_SetSourceMemoryHSize(U8 w64);
void OSD_SetDestinationMemoryPositionBase(U32 addr);
U32 OSD_GetDestinationMemoryPositionBase(void);
void OSD_SetDestinationMemoryHSize(U8 w64);
void OSD_SetWindow0MemoryPositionBase(U32 addr);
void OSD_SetWindow0MemoryHSize(U8 w64);
void OSD_SetWindow0MemoryVSize(U8 h64);
void OSD_SetWindow1MemoryPositionBase(U32 addr);
void OSD_SetWindow1MemoryHSize(U8 w64);
void OSD_SetWindow1MemoryVSize(U8 h64);
void OSD_SetWindow4MemoryPositionBase(U32 addr);
void OSD_SetWindow4MemoryHSize(U8 w64);
void OSD_SetWindow4MemoryVSize(U8 h64);
void OSD_SetWindowMemoryPosition(U8 WinNO,U16 xp,U16 yp);
void OSD_LoadLUT(U8 WinNO,U8 BitMode,const U8 *ptr);
void OSD_SetWindowInfo(U8 WinNO,U16 HStart,U16 HLength,U16 VStart,U16 VLength);
void OSD_SetBitmapColorWriteMode(U8 mode);
void OSD_BlockFill(U16 dx, U16 dy, U16 w, U16 h, U16 color, U8 DispMode);
void OSD_BlockTransfer(U16 sx, U16 sy, U16 w, U16 h, U16 dx, U16 dy,U8 DispMode);
#ifndef DP80390
void OSD_BlockTransferLinear(U32 addr, U16 w, U16 h, U16 dx, U16 dy,U8 DispMode)reentrant;
#endif
void SetColorConvertDisable(void);
void OSD_ConvertColor(U8 colorNum,U16 *cvColor, U8 DispMode);
void SetSelectiveOvWriteDisable(void);
void OSD_OverWriteColor(U8 colorNum, U16 *cvColor,U8 DispMode);
void OSD_GlobalWindowAlpha(U8 winno, U8 level);
void OSD_PerPixelAlpha(U8 winno);
void OSD_ColorKeyAlpha(U8 colorNum, U16 *color, U8 level);
void OSD_AttrAlpha_Disable(U8 WinNO);
void OSD_BlinkIntervalSetting(U8 level);
void OSD_LoadBmp(const U8 *Bptr,U16 sx,U16 sy,U8 dispMode);
void OSD_LoadFont(const U8 *Bptr,U16 sx,U16 sy,U8 dispMode,U16 Font_NumIndex);
void OSD_ShowWindowBmp(U8 WinNO,U8 on);
void OSD_Layer_Init(void);
void OSD_WaitWindowBlank(U8 winno,U8 Cnt);
void OSD_WaitOSDBlank(U8 Cnt);
void OSD_WaitDisplayBlank(U8 Cnt);
void OSD_DrawLine(U16 x1,U16 y1,U16 x2,U16 y2,U16 color,U8 DispMode);

#endif

